package com.project.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.project.bean.LssueBean;
import com.project.bean.OutLssueBean;
import com.project.service.LssueService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.time.LocalDate;

/**
 * 出库
 */
@SuppressWarnings("all")
@Controller
@RequestMapping("lssue")
public class LssueController {

    @Resource
    private LssueService lssueService;


    /**
     * 分页显示
     * @param pageNO
     * @param pageSize
     * @return
     */
    @RequestMapping("findAllLssue")
    @ResponseBody
    public IPage<LssueBean> findAllLssue(@RequestParam(value = "pageNO", defaultValue = "1") int pageNO,
                                       @RequestParam(value = "pageSize", defaultValue = "3") int pageSize){
        return lssueService.findAllLssue(pageNO,pageSize);
    }

    /**
     * 添加
     * @param lssueBean
     * @return
     */
    @RequestMapping("addLssue")
    @ResponseBody
    public String addLssue(LssueBean lssueBean){
        lssueService.addLssue(lssueBean);
        return "添加成功";
    }

    /**
     * id查询数量
     * @param id
     * @param num
     * @return
     */
    @RequestMapping("updateOutLssue")
    @ResponseBody
    public String updateOutLssue(int id,int num){
        lssueService.updateOutLssue(id,num);
        return "成功";
    }

    /**
     * 删除
     * @param lssueId
     * @return
     */
    @RequestMapping("delLssue")
    @ResponseBody
    public String delLssue(int lssueId){
        lssueService.delLssue(lssueId);
        return "删除成功";
    }


    /**
     * id查询信息
     * @param lssueId
     * @return
     */
    @RequestMapping("findId")
    @ResponseBody
    public OutLssueBean findId(int lssueId){
        return lssueService.findId(lssueId);
    }


    /**
     * 小班日期查询出库
     * @param pageNO
     * @param pageSize
     * @param lssueClass
     * @param startTime
     * @param endTime
     * @return
     */
    @RequestMapping("findName")
    @ResponseBody
    public IPage<LssueBean> findName(@RequestParam(value = "pageNO", defaultValue = "1") int pageNO,
                                     @RequestParam(value = "pageSize", defaultValue = "3") int pageSize,
                                     String lssueClass, LocalDate startTime, LocalDate endTime){
        return lssueService.findName(pageNO,pageSize,lssueClass,startTime,endTime);
    }
}
